package zy.test.graphics;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.Log;
import android.view.View;

public class MyView extends View {

	Paint paint=new Paint();
	Canvas canvas=null;
	public MyView(Context context) {
		super(context);
		paint.setColor(Color.RED);
		paint.setAntiAlias(true);
		new Timer().schedule(new TimerTask0(), 0, 1000);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		canvas.drawText(new Date().toString()+"***"+Thread.currentThread().getId(), 50, 50, paint);
		Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
		canvas.drawBitmap(bitmap, 200, 300, paint);
		for(int i=0;i<432;i++)
		{
		canvas.drawCircle(200, 400, (float)(Math.random()*100), paint);
		}
		//Log.w("tid", "ondraw:"+Thread.currentThread().getId());
		System.out.println("on draw");
	}
	
	class TimerTask0 extends TimerTask
	{
		@Override
		public void run() {
			MyView.this.postInvalidate();
			System.out.println("task");
			//Log.w("tid", "task_run:"+Thread.currentThread().getId());
			
			
		}
		
	}

}
